package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.dto.ProcureDto;
import com.example.entity.dto.ProcureDtoDto;
import com.example.entity.vo.RequisitionPurchaseVo;
import com.example.entity.yifei.*;
import com.example.mapper.*;
import com.example.service.PurchaseOrderService;
import com.example.untils.TimeUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PurchaseOrderServiceImpl implements PurchaseOrderService {

    @Resource
    private AdmmfMapper admmfMapper;
    @Resource
    private PurmaMapper purmaMapper;
    @Resource
    private PurtaMapper purtaMapper;

    @Resource
    private PurtbMapper purtbMapper;

    @Resource
    private PurtcMapper purtcMapper;

    @Resource
    private PurtdMapper purtdMapper;

    @Resource
    private PurtrMapper purtrMapper;

    @Resource
    private InvmbMapper invmbMapper;

    @Transactional
    public void add(ProcureDtoDto procureDtoDto) {
        List<ProcureDto> procureDtoList = procureDtoDto.getProcureDtoList();
        for (ProcureDto procureDto : procureDtoList) {
            String singleNo = procureDto.getSingleNo();

            String creator = procureDto.getCreator();

            Admmf admmf = admmfMapper.selectOne(new QueryWrapper<Admmf>().eq("MF001", creator));

            String usrGroup = admmf.getMf004();


            String time = TimeUtils.getNowTime().substring(0, 8);

            List<RequisitionPurchaseVo> requisitionPurchaseVoList =
                    procureDto.getRequisitionPurchaseVoList();

            Purtc purtc = new Purtc();

            String tc002 = purtcMapper.generateTc002(singleNo);

            Purma purma = purmaMapper.
                    selectOne(new QueryWrapper<Purma>().eq("MA001", procureDto.getNumber()));


            purtc.setCompany(purma.getCompany());
            purtc.setCreator(creator);
            purtc.setUsrGroup(usrGroup);
            purtc.setCreateDate(TimeUtils.getNowTime());
            purtc.setModifier("");
            purtc.setModiDate("");
            purtc.setFlag(new Double(1));
            purtc.setTc001(singleNo);
            purtc.setTc002(tc002);
            purtc.setTc003(time);
            purtc.setTc004(procureDto.getNumber());
            purtc.setTc005(purma.getMa021());
            purtc.setTc006(1.00);
            purtc.setTc007(purma.getMa026());
            purtc.setTc008(purma.getMa025());
            purtc.setTc009("");
            // 设置工厂编号 宏竹默认是01
            purtc.setTc010("01");
            purtc.setTc011(purma.getMa047());
            purtc.setTc012("");
            purtc.setTc013(0.00);
            purtc.setTc014("N");
            purtc.setTc015("");
            purtc.setTc016("");
            purtc.setTc017("");
            purtc.setTc018(purma.getMa044());
            purtc.setTc019(0.0);
            purtc.setTc020(0.00);
            purtc.setTc021("");
            purtc.setTc022("");
            purtc.setTc023(0.00);
            purtc.setTc024(time);
            purtc.setTc025("");
            purtc.setTc026(purma.getMa064());
            purtc.setTc027(purma.getMa055());
            purtc.setTc028(0.00);
            purtc.setTc029(0.00);
            purtc.setTc030("N");
            purtc.setTc031(0.00);
            purtc.setTc032("");
            purtc.setTc033("N");
            purtc.setTc034("");
            purtc.setTc035("N");
            purtc.setTc036("");
            purtc.setTc037("");
            purtc.setTc038(0.0);
            purtc.setTc039(0.00);
            purtc.setTc040(0.00);
            purtc.setTc041("");
            purtc.setTc042("");
            purtc.setTc043("0");
            purtc.setTc044(0.0);
            purtc.setTc045(0.0);
            purtc.setTc046("");
            purtc.setTc047("********************");
            purtc.setTcd01("N");

            purtcMapper.insert(purtc);

            int xh = 1;
            // 生成采购单单身
            for (RequisitionPurchaseVo requisitionPurchaseVo : requisitionPurchaseVoList) {
                Purtd purtd = new Purtd();
                Purtb purtb = purtbMapper.selectOne(new QueryWrapper<Purtb>().
                        eq("TB001", requisitionPurchaseVo.getRequisitionType()).
                        eq("TB002", requisitionPurchaseVo.getRequisitionNo()).
                        eq("TB003", requisitionPurchaseVo.getRequisitionNumber()));
                Invmb invmb = invmbMapper.selectOne(new QueryWrapper<Invmb>().
                        eq("MB001", requisitionPurchaseVo.getProductNumber()));
                purtd.setCompany(purma.getCompany());
                purtd.setCreator(creator);
                purtd.setUsrGroup(usrGroup);
                purtd.setCreateDate(TimeUtils.getNowTime());
                purtd.setModifier("");
                purtd.setModiDate("");
                purtd.setFlag(new Double(1));
                purtd.setTd001(singleNo);
                purtd.setTd002(tc002);
                purtd.setTd003(String.format("%04d", xh));
                xh++;
                purtd.setTd004(purtb.getTb004());
                purtd.setTd005(purtb.getTb005());
                purtd.setTd006(purtb.getTb006());
                purtd.setTd007(invmb.getMb017());
                purtd.setTd008(requisitionPurchaseVo.getNumber());
                purtd.setTd009(invmb.getMb004());
                purtd.setTd010(purtb.getTb017());
                purtd.setTd011(purtb.getTb018());
                purtd.setTd012(time);
                purtd.setTd013(purtb.getTb029());
                purtd.setTd014("");
                purtd.setTd015(new Double(0));
                purtd.setTd016("N");
                purtd.setTd017("");
                purtd.setTd018("N");
                purtd.setTd019(new Double(0));
                purtd.setTd020("");
                purtd.setTd021(purtb.getTb030());
                purtd.setTd022(purtb.getTb060());
                purtd.setTd023(purtb.getTb031());
                purtd.setTd024("");
                purtd.setTd025("N");
                purtd.setTd026(purtb.getTb001());
                purtd.setTd027(purtb.getTb002());
                purtd.setTd028(purtb.getTb003());
                purtd.setTd029("");
                purtd.setTd030(new Double(0));
                purtd.setTd031(new Double(0));
                purtd.setTd032("");
                purtd.setTd033(invmb.getMb111());
                purtd.setTd034(purtb.getTb018());
                purtd.setTd035(new Double(0));
                purtd.setTd036(new Double(0));
                purtd.setTd037(new Double(0));
                purtd.setTd038(invmb.getMb004());
                purtd.setTd039(requisitionPurchaseVo.getNumber());
                purtd.setTd040("");
                purtd.setTd041("");
                purtd.setTd042("");
                purtd.setTd043("");
                purtd.setTd044("");
                purtd.setTd045(new Double(0));
                purtd.setTd046(new Double(0));
                purtd.setTd047(new Double(0));
                purtd.setTd048(new Double(0));
                purtd.setTd049(new Double(0));
                purtd.setTdc01(new Double(0));
                purtd.setTdc02(new Double(0));
                purtd.setTdc03("2");
                purtd.setTdc04(new Double(0));
                purtd.setTdc05(new Double(0));
                purtd.setTdc06(new Double(0));
                purtd.setTd050("");
                purtd.setTd051("");

                purtdMapper.insert(purtd);
                // 生成单身的时候需要回写到 PURTR 首先删除所有采购码为空的N PURTR
                QueryWrapper<Purtr> purtrQueryWrapper = new QueryWrapper<>();
                purtrQueryWrapper.eq("TR001", requisitionPurchaseVo.getRequisitionType()).
                        eq("TR002", requisitionPurchaseVo.getRequisitionNo()).
                        eq("TR003", requisitionPurchaseVo.getRequisitionNumber());

                List<Purtr> purtrList = purtrMapper.selectList(purtrQueryWrapper);
                for (Purtr purtr : purtrList) {
                    System.out.println("delete purtr" + purtr.getTr017());
                    if (purtr.getTr017().equals("N")) {

                        System.out.println("hhhhh");

                        QueryWrapper<Purtr> deleteQueryWrapper = new QueryWrapper<>();
                        deleteQueryWrapper.eq("TR001", requisitionPurchaseVo.getRequisitionType()).
                                eq("TR002", requisitionPurchaseVo.getRequisitionNo()).
                                eq("TR003", requisitionPurchaseVo.getRequisitionNumber()).
                                eq("TR007", purtr.getTr004());
                        purtrMapper.delete(deleteQueryWrapper);
                    }

                }

                Purtr purtr = new Purtr();

                purtr.setCompany(purma.getCompany());
                purtr.setCreator(creator);
                purtr.setUsrGroup(usrGroup);
                purtr.setCreateDate(TimeUtils.getNowTime());
                purtr.setModifier("");
                purtr.setModiDate("");
                purtr.setFlag(new Double(1));

                purtr.setTr001(requisitionPurchaseVo.getRequisitionType());
                purtr.setTr002(requisitionPurchaseVo.getRequisitionNo());
                purtr.setTr003(requisitionPurchaseVo.getRequisitionNumber());

                String serialNumber =
                        purtrMapper.selectCountTr004(requisitionPurchaseVo.getRequisitionType(), requisitionPurchaseVo.getRequisitionNo(), requisitionPurchaseVo.getRequisitionNumber());

                System.out.println(serialNumber);
                purtr.setTr004(String.format("%04d", Integer.parseInt(serialNumber.trim())));
                purtr.setTr005(requisitionPurchaseVo.getSupplierNo());
                purtr.setTr006(requisitionPurchaseVo.getNumber());
                purtr.setTr007(requisitionPurchaseVo.getNumber() / purtb.getTb009());
                purtr.setTr008(requisitionPurchaseVo.getUnit());
                purtr.setTr009(purtb.getTb016());
                purtr.setTr010(purtb.getTb017());
                purtr.setTr011(purtb.getTb018());
                purtr.setTr012(purma.getMa044());
                purtr.setTr013(time);
                purtr.setTr014(invmb.getMb017());
                purtr.setTr015(purtd.getTd025());
                purtr.setTr016(purtd.getTd014());
                purtr.setTr017("Y");
                purtr.setTr018("N");
                purtr.setTr019("");
                purtr.setTr020(new Double(0.0));
                purtr.setTr021("");
                purtr.setTr022(new Double(0.0));
                purtr.setTr023(new Double(0.0));
                purtr.setTr024("");
                purtr.setTr025("");
                purtr.setTr026(purtd.getTd038());
                purtr.setTr027(requisitionPurchaseVo.getNumber());
                purtr.setTr028("");
                purtr.setTr029("");
                purtr.setTr030("");
                purtr.setTr031(new Double(0.0));
                purtr.setTr032(new Double(0.0));
                purtr.setTr033(new Double(0.0));
                purtr.setTr034("********************");

                purtrMapper.insert(purtr);


                String tb039 = "N";
                System.out.println(purtb.getTb048());
                System.out.println(requisitionPurchaseVo.getNumber());
                if (purtb.getTb048().compareTo(requisitionPurchaseVo.getNumber()) == 0)
                    tb039 = "Y";
                purtbMapper.updateByTb001WithTb002WithTb003(requisitionPurchaseVo.getRequisitionType(),
                        requisitionPurchaseVo.getRequisitionNo(),
                        requisitionPurchaseVo.getRequisitionNumber(),tb039,purtb.getTb048() - requisitionPurchaseVo.getNumber(),purtb.getUdf51());

            }


        }


        /*
        //List<Procure> procureList = procureDto.getProcureList();
        List<RequisitionPurchaseVo> requisitionPurchaseVoList =
                procureDto.getRequisitionPurchaseVoList();

        // 先获取不同的供应商
        HashSet<String> hashSet = new HashSet<String>();
        for (RequisitionPurchaseVo requisitionPurchaseVo : requisitionPurchaseVoList) {
            hashSet.add(requisitionPurchaseVo.getSupplierNo());
        }

        for (String s : hashSet) {
            // 生成采购单单头信息
            Purtc purtc = new Purtc();

            String tc002 = purtcMapper.generateTc002(singleNo);

            Purma purma = purmaMapper.
                    selectOne(new QueryWrapper<Purma>().eq("MA001", s));


            purtc.setCompany(purma.getCompany());
            purtc.setCreator(creator);
            purtc.setUsrGroup(usrGroup);
            purtc.setCreateDate(TimeUtils.getNowTime());
            purtc.setModifier("");
            purtc.setModiDate("");
            purtc.setFlag(new Double(1));
            purtc.setTc001(singleNo);
            purtc.setTc002(tc002);
            purtc.setTc003(time);
            purtc.setTc004(s);
            purtc.setTc005(purma.getMa021());
            purtc.setTc006(1.00);
            purtc.setTc007(purma.getMa026());
            purtc.setTc008(purma.getMa025());
            purtc.setTc009("");
            // 设置工厂编号 宏竹默认是01
            purtc.setTc010("01");
            purtc.setTc011(purma.getMa047());
            purtc.setTc012("");
            purtc.setTc013(0.00);
            purtc.setTc014("N");
            purtc.setTc015("");
            purtc.setTc016("");
            purtc.setTc017("");
            purtc.setTc018(purma.getMa044());
            purtc.setTc019(0.0);
            purtc.setTc020(0.00);
            purtc.setTc021("");
            purtc.setTc022("");
            purtc.setTc023(0.00);
            purtc.setTc024(time);
            purtc.setTc025("");
            purtc.setTc026(purma.getMa064());
            purtc.setTc027(purma.getMa055());
            purtc.setTc028(0.00);
            purtc.setTc029(0.00);
            purtc.setTc030("N");
            purtc.setTc031(0.00);
            purtc.setTc032("");
            purtc.setTc033("N");
            purtc.setTc034("");
            purtc.setTc035("N");
            purtc.setTc036("");
            purtc.setTc037("");
            purtc.setTc038(0.0);
            purtc.setTc039(0.00);
            purtc.setTc040(0.00);
            purtc.setTc041("");
            purtc.setTc042("");
            purtc.setTc043("0");
            purtc.setTc044(0.0);
            purtc.setTc045(0.0);
            purtc.setTc046("");
            purtc.setTc047("********************");
            purtc.setTcd01("N");

            int xh = 1;
            // 生成采购单单身
            for (RequisitionPurchaseVo requisitionPurchaseVo : requisitionPurchaseVoList) {
                if (requisitionPurchaseVo.getSupplierNo().equals(s)) {
                    Purtd purtd = new Purtd();
                    Purtb purtb = purtbMapper.selectOne(new QueryWrapper<Purtb>().
                            eq("TB001", requisitionPurchaseVo.getRequisitionType()).
                            eq("TB002", requisitionPurchaseVo.getRequisitionNo()).
                            eq("TB003", requisitionPurchaseVo.getRequisitionNumber()));
                    Invmb invmb = invmbMapper.selectOne(new QueryWrapper<Invmb>().
                            eq("MB001", requisitionPurchaseVo.getProductNumber()));
                    purtd.setCompany(purma.getCompany());
                    purtd.setCreator(creator);
                    purtd.setUsrGroup(usrGroup);
                    purtd.setCreateDate(TimeUtils.getNowTime());
                    purtd.setModifier("");
                    purtd.setModiDate("");
                    purtd.setFlag(new Double(1));
                    purtd.setTd001(singleNo);
                    purtd.setTd002(tc002);
                    purtd.setTd003(String.format("%04d", xh));
                    xh++;
                    purtd.setTd004(purtb.getTb004());
                    purtd.setTd005(purtb.getTb005());
                    purtd.setTd006(purtb.getTb006());
                    purtd.setTd007(invmb.getMb017());
                    purtd.setTd008(requisitionPurchaseVo.getNumber());
                    purtd.setTd009(invmb.getMb004());
                    purtd.setTd010(purtb.getTb017());
                    purtd.setTd011(purtb.getTb018());
                    purtd.setTd012(time);
                    purtd.setTd013(purtb.getTb029());
                    purtd.setTd014("");
                    purtd.setTd015(new Double(0));
                    purtd.setTd016("N");
                    purtd.setTd017("");
                    purtd.setTd018("N");
                    purtd.setTd019(new Double(0));
                    purtd.setTd020("");
                    purtd.setTd021(purtb.getTb030());
                    purtd.setTd022(purtb.getTb060());
                    purtd.setTd023(purtb.getTb031());
                    purtd.setTd024("");
                    purtd.setTd025("N");
                    purtd.setTd026(purtb.getTb001());
                    purtd.setTd027(purtb.getTb002());
                    purtd.setTd028(purtb.getTb003());
                    purtd.setTd029("");
                    purtd.setTd030(new Double(0));
                    purtd.setTd031(new Double(0));
                    purtd.setTd032("");
                    purtd.setTd033(invmb.getMb111());
                    purtd.setTd034(purtb.getTb018());
                    purtd.setTd035(new Double(0));
                    purtd.setTd036(new Double(0));
                    purtd.setTd037(new Double(0));
                    purtd.setTd038(invmb.getMb004());
                    purtd.setTd039(requisitionPurchaseVo.getNumber());
                    purtd.setTd040("");
                    purtd.setTd041("");
                    purtd.setTd042("");
                    purtd.setTd043("");
                    purtd.setTd044("");
                    purtd.setTd045(new Double(0));
                    purtd.setTd046(new Double(0));
                    purtd.setTd047(new Double(0));
                    purtd.setTd048(new Double(0));
                    purtd.setTd049(new Double(0));
                    purtd.setTdc01(new Double(0));
                    purtd.setTdc02(new Double(0));
                    purtd.setTdc03("2");
                    purtd.setTdc04(new Double(0));
                    purtd.setTdc05(new Double(0));
                    purtd.setTdc06(new Double(0));
                    purtd.setTd050("");
                    purtd.setTd051("");

                    purtdMapper.insert(purtd);
                    // 生成单身的时候需要回写到 PURTR 首先删除所有采购码为空的N PURTR
                    QueryWrapper<Purtr> purtrQueryWrapper = new QueryWrapper<>();
                    purtrQueryWrapper.eq("TR001", requisitionPurchaseVo.getRequisitionType()).
                            eq("TR002", requisitionPurchaseVo.getRequisitionNo()).
                            eq("TR003", requisitionPurchaseVo.getRequisitionNumber());

                    List<Purtr> purtrList = purtrMapper.selectList(purtrQueryWrapper);
                    for (Purtr purtr : purtrList) {
                        if (purtr.getTr017() == "N") {
                            QueryWrapper<Purtr> deleteQueryWrapper = new QueryWrapper<>();
                            deleteQueryWrapper.eq("TR001", requisitionPurchaseVo.getRequisitionType()).
                                    eq("TR002", requisitionPurchaseVo.getRequisitionNo()).
                                    eq("TR003", requisitionPurchaseVo.getRequisitionNumber()).
                                    eq("TR007", purtr.getTr004());
                            purtrMapper.delete(deleteQueryWrapper);
                        }

                    }

                    Purtr purtr = new Purtr();

                    purtr.setCompany(purma.getCompany());
                    purtr.setCreator(creator);
                    purtr.setUsrGroup(usrGroup);
                    purtr.setCreateDate(TimeUtils.getNowTime());
                    purtr.setModifier("");
                    purtr.setModiDate("");
                    purtr.setFlag(new Double(1));

                    purtr.setTr001(requisitionPurchaseVo.getRequisitionType());
                    purtr.setTr002(requisitionPurchaseVo.getRequisitionNo());
                    purtr.setTr003(requisitionPurchaseVo.getRequisitionNumber());

                    String serialNumber =
                            purtrMapper.selectCountTr004(requisitionPurchaseVo.getRequisitionType(), requisitionPurchaseVo.getRequisitionNo(), requisitionPurchaseVo.getRequisitionNumber());

                    purtr.setTr004(String.format("%04d", serialNumber));
                    purtr.setTr005(requisitionPurchaseVo.getSupplierNo());
                    purtr.setTr006(requisitionPurchaseVo.getNumber());
                    purtr.setTr007(requisitionPurchaseVo.getNumber() / purtb.getTb009());
                    purtr.setTr008(requisitionPurchaseVo.getUnit());
                    purtr.setTr009(purtb.getTb016());
                    purtr.setTr010(purtb.getTb017());
                    purtr.setTr011(purtb.getTb018());
                    purtr.setTr012(purma.getMa044());
                    purtr.setTr013(time);
                    purtr.setTr014(invmb.getMb017());
                    purtr.setTr015(purtd.getTd025());
                    purtr.setTr016(purtd.getTd014());
                    purtr.setTr017("Y");
                    purtr.setTr018("N");
                    purtr.setTr019("");
                    purtr.setTr020(new Double(0.0));
                    purtr.setTr021("");
                    purtr.setTr022(new Double(0.0));
                    purtr.setTr023(new Double(0.0));
                    purtr.setTr024("");
                    purtr.setTr025("");
                    purtr.setTr026(purtd.getTd038());
                    purtr.setTr027(requisitionPurchaseVo.getNumber());
                    purtr.setTr028("");
                    purtr.setTr029("");
                    purtr.setTr030("");
                    purtr.setTr031(new Double(0.0));
                    purtr.setTr032(new Double(0.0));
                    purtr.setTr033(new Double(0.0));
                    purtr.setTr034("********************");

                    purtrMapper.insert(purtr);

                }
            }

            purtcMapper.insert(purtc);
        }*/


       /* for (RequisitionPurchaseVo requisitionPurchaseVo : requisitionPurchaseVoList) {

            // 生成采购单单头信息
            Purtc purtc = new Purtc();

            String tc002 = purtcMapper.generateTc002(singleNo);

            Purma purma = purmaMapper.
                    selectOne(new QueryWrapper<Purma>().eq("MA001", requisitionPurchaseVo.getSupplierNo()));

            purtc.setCompany(purma.getCompany());
            purtc.setCreator(creator);
            purtc.setUsrGroup(usrGroup);
            purtc.setCreateDate(TimeUtils.getNowTime());
            purtc.setModifier("");
            purtc.setModiDate("");
            purtc.setFlag(new Double(1));
            purtc.setTc001(singleNo);
            purtc.setTc002(tc002);
            purtc.setTc003(time);
            purtc.setTc004(requisitionPurchaseVo.getSupplierNo());
            purtc.setTc005(purma.getMa021());
            purtc.setTc006(1.00);
            purtc.setTc007(purma.getMa026());
            purtc.setTc008(purma.getMa025());
            purtc.setTc009("");
            // 设置工厂编号 宏竹默认是01
            purtc.setTc010("01");
            purtc.setTc011(purma.getMa047());
            purtc.setTc012("");
            purtc.setTc013(0.00);
            purtc.setTc014("N");
            purtc.setTc015("");
            purtc.setTc016("");
            purtc.setTc017("");
            purtc.setTc018(purma.getMa044());
            purtc.setTc019(0.0);
            purtc.setTc020(0.00);
            purtc.setTc021("");
            purtc.setTc022("");
            purtc.setTc023(0.00);
            purtc.setTc024(time);
            purtc.setTc025("");
            purtc.setTc026(purma.getMa064());
            purtc.setTc027(purma.getMa055());
            purtc.setTc028(0.00);
            purtc.setTc029(0.00);
            purtc.setTc030("N");
            purtc.setTc031(0.00);
            purtc.setTc032("");
            purtc.setTc033("N");
            purtc.setTc034("");
            purtc.setTc035("N");
            purtc.setTc036("");
            purtc.setTc037("");
            purtc.setTc038(0.0);
            purtc.setTc039(0.00);
            purtc.setTc040(0.00);
            purtc.setTc041("");
            purtc.setTc042("");
            purtc.setTc043("0");
            purtc.setTc044(0.0);
            purtc.setTc045(0.0);
            purtc.setTc046("");
            purtc.setTc047("********************");
            purtc.setTcd01("N");

            // 生成采购单单身信息
            Purtd purtd = new Purtd();
            Purtb purtb = purtbMapper.selectOne(new QueryWrapper<Purtb>().
                    eq("TB001", requisitionPurchaseVo.getRequisitionType()).
                    eq("TB002", requisitionPurchaseVo.getRequisitionNo()).
                    eq("TB003", requisitionPurchaseVo.getRequisitionNumber()));
            Invmb invmb = invmbMapper.selectOne(new QueryWrapper<Invmb>().
                    eq("MB001",requisitionPurchaseVo.getProductNumber()));
            purtd.setCompany(purma.getCompany());
            purtd.setCreator(creator);
            purtd.setUsrGroup(usrGroup);
            purtd.setCreateDate(TimeUtils.getNowTime());
            purtd.setModifier("");
            purtd.setModiDate("");
            purtd.setFlag(new Double(1));
            purtd.setTd001(singleNo);
            purtd.setTd002(tc002);
            purtd.setTd003("0001");
            purtd.setTd004(purtb.getTb004());
            purtd.setTd005(purtb.getTb005());
            purtd.setTd006(purtb.getTb006());
            purtd.setTd007(invmb.getMb017());
            purtd.setTd008(purtb.getTb009());
            purtd.setTd009(invmb.getMb004());
            purtd.setTd010(purtb.getTb017());
            purtd.setTd011(purtb.getTb018());
            purtd.setTd012(time);
            purtd.setTd013(purtb.getTb029());
            purtd.setTd014("");
            purtd.setTd015(new Double(0));
            purtd.setTd016("N");
            purtd.setTd017("");
            purtd.setTd018("N");
            purtd.setTd019(new Double(0));
            purtd.setTd020("");
            purtd.setTd021(purtb.getTb030());
            purtd.setTd022(purtb.getTb060());
            purtd.setTd023(purtb.getTb031());
            purtd.setTd024("");
            purtd.setTd025("N");
            purtd.setTd026(purtb.getTb001());
            purtd.setTd027(purtb.getTb002());
            purtd.setTd028(purtb.getTb003());
            purtd.setTd029("");
            purtd.setTd030(new Double(0));
            purtd.setTd031(new Double(0));
            purtd.setTd032("");
            purtd.setTd033(invmb.getMb111());
            purtd.setTd034(purtb.getTb018());
            purtd.setTd035(new Double(0));
            purtd.setTd036(new Double(0));
            purtd.setTd037(new Double(0));
            purtd.setTd038(invmb.getMb004());
            purtd.setTd039(purtb.getTb009());
            purtd.setTd040("");
            purtd.setTd041("");
            purtd.setTd042("");
            purtd.setTd043("");
            purtd.setTd044("");
            purtd.setTd045(new Double(0));
            purtd.setTd046(new Double(0));
            purtd.setTd047(new Double(0));
            purtd.setTd048(new Double(0));
            purtd.setTd049(new Double(0));
            purtd.setTdc01(new Double(0));
            purtd.setTdc02(new Double(0));
            purtd.setTdc03("2");
            purtd.setTdc04(new Double(0));
            purtd.setTdc05(new Double(0));
            purtd.setTdc06(new Double(0));
            purtd.setTd050("");
            purtd.setTd051("");

            purtcMapper.insert(purtc);
            purtdMapper.insert(purtd);

        }
*/

    }

}
